// components/tabbar/index.js
const app = getApp();
const baseUrl = app.globalData.baseUrl;
Component({
  /**
   * 组件的属性列表
   */
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    active:0,
    list: [{
        key: "AIteacher",
        icon: "/assets/tab1.png",
        iconActive: "/assets/tab1-a.png",
        label: "AI老师",
        url: "/pages/AIteacher/index"
      },
      {
        key: "workbook",
        icon: "/assets/tab2.png",
        iconActive: "/assets/tab2-a.png",
        label: "练习册",
        url: "/pages/workbook/index"
      },
      {
        key: "my",
        icon: "/assets/tab3.png",
        iconActive: "/assets/tab3.png",
        label: "个人中心",
        url:"/pages/my/index"
      },
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    setKey(e) {
      const index = e.currentTarget.dataset.active
      wx.switchTab({
        url: this.data.list[index].url
      });
      this.setData({
        active: index,
      })
      console.log("active==========:", this.data.active)
    },
    authSubscriptions(e) {
      const that = this;
      const tmplIds = app.globalData.tmplIds;
      wx.requestSubscribeMessage({
        tmplIds,
        complete: function (res) {
          console.log("requestSubscribeMessage-complete:", res);
          that.setData({
            overlayShow: false
          });
        }
      });
    }
  }
});